package nio;

import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;

/**
 * <b> 描述:</b> ;<br/>
 *
 * @author <b>作者</b>cdxuhongya@jd.com
 *         <b>时间</b>2017/3/1 15:27<br/>
 *         <b>@CopyRight (c) </b>2015-京东智能版权所有<br/>
 */
public class FIleChannelTransferto {
    public static void main(String[] args) throws Exception{

        RandomAccessFile file = new RandomAccessFile("D:\\text.txt","rw");
        FileChannel channel = file.getChannel();
        RandomAccessFile file1 = new RandomAccessFile("D:\\text2.txt","rw");
        FileChannel channel1 = file1.getChannel();
        long position = 0;
        long count = channel.size();
        channel.transferTo(position,count,channel1);
    }
}
